package WaiBao;

import java.util.Arrays;

public class MaSiLuan {
    public static void main(String[] args) {
        String[] name = {"杨清柠(班长)", "王道(副班长)", "小李(学习委员)", "王大壮(体育委员)", "李凯", "小值", "李思文", "小寻", "小阳", "贾探春", "李小彪", "小子",
                "小战", "王博文", "小晗", "小兴", "李凯子", "小愈", "小易", "王涛涛", "小贺", "小白", "小修", "李小龙", "小金", "小颇", "小恬", "王特特",
                "王一博", "马思銮(学生)"};//考生本人:马思銮(学生)
        int[] age = {21, 20, 20, 18, 21, 20, 21, 20, 19,20, 18, 18, 20, 21, 21, 19, 18, 19, 18, 20, 19, 19, 20, 20, 20, 18, 20, 21, 20, 20};//考生年龄20

        double[] mingyao1 = {77, 72, 84, 70, 79, 69, 78, 89, 85, 80, 91, 87, 85, 89, 65, 65, 99, 99, 96, 88, 92, 91, 95, 65, 85, 74, 91, 74, 85, 96};
        double[] mingyao2 = {76, 85, 69, 76, 78, 77, 74, 69, 70, 70, 90, 77, 76, 95, 65, 65, 76, 99, 66, 98, 72, 71, 95, 96, 76, 86, 84, 68, 70, 95};
        double[] mingyao3 = {87, 76, 84, 85, 77, 66, 78, 64, 80, 80, 93, 87, 85, 65, 65, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 84, 73, 75, 84, 96};


        double xuexia1;//代表每个学生的总分
        double xuexia2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            xuexia1 = mingyao1[i] + mingyao2[i] + mingyao3[i];
//            xuexia2 = (xuexia1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + xuexia1);
//            System.out.println(name[i] + "的平均分为:" + xuexia2);
//        }

        double qiao1 = 0, qiao2 = 0;
        double[] jia = new double[30];
//        for (int i = 0; i < 30; i++) {
//            qiao1= mingyao1[i] +mingyao2[i] + mingyao3[i];
//            qiao2 = (qiao1 * 1.0) / 3;
//            jia[i] = qiao2;
//        }
//
//        for (int i = 0; i < jia.length - 1; i++) {
//            for (int j = 0; j < jia.length - i - 1; j++) {
//                if (jia[j] < jia[j + 1]) {
//                    double tep = jia[j];
//                    jia[j] =jia[j + 1];
//                    jia[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(jia[i]);
//        }


        double yongqi1 = 0,  yongqi2 = 0,  yongqi3 = 0;//计算每门课的平均分
        double mianzi1 = 0, mianzi2 = 0, mianzi3 = 0;//计算每门课标准差
        double rangni1 = 0, rangni2 = 0, rangni3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i <mingyao1.length; i++) {
            he += mingyao1[i];
        }
        yongqi1 = (he * 1.0) / 30;
        System.out.println("生物化学的班级平均分为:" +  yongqi1);
        double Sum = 0;
        for (int i = 0; i < mingyao2.length; i++) {
            Sum +=mingyao2[i];
        }
        yongqi2 = (Sum * 1.0) / 30;
        System.out.println("物理化学的班级平均分为:" +  yongqi2);
        double sum = 0;
        for (int i = 0; i < mingyao3.length; i++) {
            sum +=mingyao3[i];
        }
        yongqi3 = (sum * 1.0) / 30;
        System.out.println("电子与电工技术的班级平均分为:" +  yongqi3);


        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i <mingyao1.length; i++) {
            c1 += (mingyao1[i] - yongqi1) * (mingyao1[i] - yongqi1);
        }
        mianzi1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:" + mianzi1);
        for (int i = 0; i < mingyao2.length; i++) {
            c2 += (mingyao2[i] -  yongqi2) * (mingyao2[i] - yongqi2);
        }
        mianzi2 = Math.sqrt(c2*1.0/30);
        System.out.println("物理化学的班级标准差为:" + mianzi2);

        for (int i = 0; i < mingyao3.length; i++) {
            c3 += (mingyao3[i] - yongqi3) * (mingyao3[i] -  yongqi3);
        }
        mianzi3 = Math.sqrt(c3*1.0/30);
        System.out.println("电子与电工技术的班级标准差为:" + mianzi3);
////
//
//
        Arrays.sort(mingyao1);
        Arrays.sort(mingyao2);
        Arrays.sort(mingyao3);
        rangni1 = (mingyao1[14] + mingyao2[15]) * 1.0 / 2;
        rangni2 = (mingyao2[14] + mingyao2[15]) * 1.0 / 2;
        rangni3 = (mingyao3[14] + mingyao3[15]) * 1.0 / 2;
        System.out.println("生物化学的中位数为:" + rangni1);
        System.out.println("物理化学的中位数为:" + rangni2);
        System.out.println("电子与电工技术的中位数为:" + rangni3);
//


    }
}
